﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace Web.Models
{
    public sealed class HoteluchoContext : DbContext
    {
        private static HoteluchoContext _instance;
        public static HoteluchoContext Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new HoteluchoContext();
                }
                return HoteluchoContext._instance;
            }
        }

        public HoteluchoContext()
            : base("DefaultConnection")
        {
        }

        public DbSet<Cliente> Clientes { get; set; }
        public DbSet<Categoria> Categorias { get; set; }
        public DbSet<Habitacion> Habitaciones { get; set; }
        public DbSet<Reserva> Reservas { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Categoria>()
                .HasMany(u => u.Habitaciones);
        }

        public override int SaveChanges()
        {
            return base.SaveChanges();
        }
    }
}